package com.symone.webcms.model.vo;

import com.symone.webcms.model.SlidePicture;
import lombok.Data;

import java.util.Date;
@Data
public class SlidePictureVO {
    private Long id;
    private Long slideId;
    private String lang;
    private String title;
    private String description;
    private String image;
    private String video;
    private Integer sorting;
    private Boolean using;
    private Boolean deleted;
    private String createUser;
    private Date createTime;

    public SlidePictureVO(SlidePicture sp){
        this.id = sp.getId();
        this.slideId = sp.getSlideId();
        this.title = sp.getTitle();
        this.lang = sp.getLang();
        this.description = sp.getDescription();
        this.image = sp.getImage();
        this.video = sp.getVideo();
        this.sorting = sp.getSorting();
        this.deleted = sp.getDeleted();
        this.createUser = sp.getCreateUser();
        this.createTime = sp.getCreateTime();
        Date now = new Date();
        if( sp.getBeginTime() == null && sp.getEndTime() == null) {
            this.using = true;
        }else if (sp.getBeginTime() != null && sp.getBeginTime().before(now) || sp.getEndTime() != null && sp.getEndTime().after(now)){
            this.using = true;
        }else{
            this.using = false;
        }
    }
}
